﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OF.Component.BLL;
using OF.Component.Model;
using OF.Component.Base;
using OF.Utility;

namespace _2010web.Manage.authority
{
    public partial class SystemEdit : OpBasePage
    {
        protected int intID = 0;
        protected int intCID = 0;
        protected string strMessage = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            SetPageCode(101, 10102);
            if (!Page.IsPostBack)
            {
                intID = RequestUtility.GetQueryInt("ID", -1);
                intCID = RequestUtility.GetQueryInt("cid", -1);
                if (intID > -1)
                {
                    AuthoritySystemInfo info = AuthoritySystemOperate.GetByID(intID);
                    this.txtName.Text = info.SystemName;
                    this.txtRemark.Text = info.Remark;
                    
                }
                
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string MessageInfo = "信息修改成功！";
            intID = RequestUtility.GetQueryInt("ID", -1);
            AuthoritySystemInfo info;
            info = AuthoritySystemOperate.GetByID(intID);
            if (info == null)
            {
                info = new AuthoritySystemInfo();
            }
            info.SystemName = txtName.Text;
            info.Remark = txtRemark.Text;
            info.SystemID = intID;
            info.IsActive = 1;
            info.UpdateTime = DateTime.Now;
            if (info.SystemID > 0)
            {
                AuthoritySystemOperate.Update(info);
            }
            else
            {
                MessageInfo = "信息创建成功！";
                info.SystemID = AuthoritySystemOperate.GetMaxID();
                info.CreateDateTime = DateTime.Now;
                AuthoritySystemOperate.Insert(info);
            }
            strMessage = MessageDivInfo(MessageInfo, "");
        }
    }
}
